package cn.tedu.common.pojo;

import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;

/**
 * 统一结果出参
 * T type的首字母
 */
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class JsonResult<T> {

    /**
     * 状态码
     */
    Integer code;

    /**
     * 状态码描述
     */
    String msg;

    /**
     * 接口的出参的具体的数据
     */
    T data;

    public static JsonResult ok(Object object,String msg){
        JsonResult jsonResult = new JsonResult<>();
        jsonResult.setCode(2000);
        jsonResult.setMsg(msg); //可选
        jsonResult.setData(object);
        return jsonResult;
    }

    public static JsonResult ok(Object object){
        return ok(object,null);
    }

}
